<?php

require_once(SY_DIR . '/helpers/HTMLElement.php');

class FormElement_Hidden extends FormElement
{

  public $defaultValue;

  public function render($row, $action)
  {
    switch ($action) {
      case Form::ACTION_EDIT :
      case Form::ACTION_CREATE :
      case Form::ACTION_OPTIONS :
        $this->beforeRender($row, $action);

        $value = $this->getValue($row);

        if (empty($value)) {
          $value = $this->defaultValue;
        }

        $inputParams = array('type' => 'hidden', 'name' => $this->getName(), 'value' => $value);

        $input = new HTMLElement('input', $inputParams);

        $output = $input;
        $output = $this->afterRender($output, $row, $action);

        return $output;

        break;
    }

    return parent::render($row, $action);
  }

}

?>